﻿@model Dyd.BaseService.ConfigManager.Domain.Model.tb_project_model
@using XXF.Extensions;
@using Dyd.BaseService.ConfigManager.Domain.Model
@{
    ViewBag.Title = "项目配置详情";
    Layout = "~/Views/Shared/_Layout.cshtml";
    IList<tb_category_model> categoryList = ViewBag.CategoryList as IList<tb_category_model>;
}
<div class="head">
    <div class="top">
        <h3 class="fl">@ViewBag.Title</h3>
        <a href="javascript:void(0);" class="back fr">返回</a>
    </div>
</div>
<div>
    @using (Html.BeginForm("ProjectAdd", "Project"))
    {
        @Html.AntiForgeryToken()
        <ul class="mydetail">
            <li>
                @Html.LabelFor(model => model.projectname)
                @Html.TextBoxFor(model => model.projectname, new { disabled = "disabled " })
                @Html.ValidationMessageFor(model => model.projectname)
            </li>

            <li>
                @Html.LabelFor(model => model.remark)
                @Html.TextAreaFor(model => model.remark, new { disabled = "disabled " })
                @Html.ValidationMessageFor(model => model.remark)
            </li>
            <li>
                <div>
                    <a href="@Url.Action("ProjectEdit", "Project", new { id=Model.id})" target="_blank" class="btn1">编辑项目分类</a>
                    <input style="width:80px;margin-left:20px;" id="showHide" type="button" class="btn1" value="显示隐藏" />
                </div>
                @{var index = 0;}

                <div style="margin-left:50px;">
                    <div style="width:95%;">
                        <div style="margin:10px;">分类继承关系:</div>@foreach (var category in Model.tb_category_model.Reverse())
                        {
                            @Html.Raw(index != 0 ? "->" : "")
                            index++;
                            <span style="font-weight:bold; font-size:15px;">@category.name</span>
                        }
                    </div>
                </div>
                <div style="margin-left:50px; ">

                    <table width="95%;">
                        <tr>
                            <td width="5%;">继承</td>
                            <td width="30%;">配置键</td>
                            <td width="30%;">配置信息</td>
                            <td width="20%;">操作</td>
                        </tr>

                        @foreach (var category in Model.tb_category_model)
                        {
                            <tr>
                                <td>↑</td>
                                <td colspan="2" style="text-align:left">分类: <span style="font-weight:bold; font-size:15px;">@category.name</span></td>

                                <td style="text-align:left"><a href="@Url.Action("ConfigAdd","Config")">添加配置</a> <a href="@Url.Action("ProjectIndex", "Project", new {categoryid=category.id })" target="_blank">相关项目</a></td>
                            </tr>
                            foreach (var config in category.tb_config_model)
                            {
                                string bgcolor = config.InheritanceFlag ? "#BA8DBA" : "#DEEDF4";
                                <tr class="configItem" style="background-color:@bgcolor;" data-flag="@config.InheritanceFlag">
                                    <td> </td>
                                    <td style="@(config.InheritanceFlag?"text-decoration:line-through;":"")">@config.configkey</td>
                                    <td style="text-align:left;@(config.InheritanceFlag?"text-decoration:line-through;":"")" title="@config.configvalue">
                                        配置值:@config.configvalue.SubString3(30)
                                        @if (config.loadbalancealgorithmenum >= 0)
                                        {
                                            <br />
                                            <span>负载均衡: <span style="color: green">启用</span></span>
                                        }
                                        @if (config.failoversequence >= 0)
                                        {
                                            <br /><span>故障转移: <span style="color: green">启用</span> @Html.Raw(config.failoversequence > 0 ? "<span style='color:red'>故障中</span>" : "")</span>
                                        }
                                    </td>

                                    <td style="text-align:left"><a target="_blank" href="@Url.Action("ConfigEdit", "Config", new { id=config.id })">编辑配置</a></td>
                                </tr>
                            }
                        }
                    </table>
                </div>
            </li>
            <li>
                <input id="return" type="button" class="btn1" value="返回" />
                @Html.ValidationMessage("Error")
            </li>
        </ul>
    }
</div>
@section Scripts{
    <script>
        $(function () {
            $("#return").on("click", function () {
                window.history.go(-1);
            });

            $("#showHide").on("click", function () {

                $(".configItem").toggle();
            });
        });

    </script>
}